using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rotempco.Core.Logging.Objects;
using Rotempco.Core.Logging.EntityObjects.Objects;

namespace Rotempco.Core.Logging.Logic
{
    internal class LogStackConverter
    {
        internal static string ToHTMLString(LogStack logEntry)
        {
            StringBuilder returnString = new StringBuilder();

            returnString.AppendLine("Source server: <b>" + logEntry.SourceMachineName + "</b><br />");
            returnString.AppendLine("Log date: <b>" + logEntry.TimeStamp.ToString("yyyy-MM-dd HH:mm:ss") + "</b><br />");
            returnString.AppendLine("<br />");
            returnString.AppendLine("<b>Message:</b> " + logEntry.Message.Replace(Environment.NewLine, "<br />") + "<br />");
            returnString.AppendLine("<b>Class:</b> " + logEntry.ClassName + "<br />");
            returnString.AppendLine("<b>Method:</b> " + logEntry.Method + "<br />");
            returnString.AppendLine("<b>SourceMachineName:</b> " + logEntry.SourceMachineName + "<br /><br />");
            if (logEntry.Exception != null)
            {
                returnString.AppendLine();
                returnString.AppendLine("<b>Stacktrace:</b><br>" + logEntry.Exception.Replace(Environment.NewLine,"<br />"));
            }

            return returnString.ToString();
        }

        internal static string ToPlainString(LogStack logEntry)
        {
            return logEntry.ToString();
        }

    }
}
